﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>管理子菜单</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="../../CSS/bootstrap3.2/css/bootstrap.css" rel="stylesheet">
    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script src="../../Scripts/avalon.js"></script>
    <script src="../../Scripts/B2CCommon.js"></script>
    <script>
        var model = avalon.define({
            $id: "MangnerSPLB",
            PID: ComFunJS.getQueryString("PID")?ComFunJS.getQueryString("PID"):"1",
            NOrder: "",
            NName: "",
            modedata: [],
            adddata: function () {
                $.post("DLLAjaxHandler.ashx", { Action: "addSPLB", Sorder: model.NOrder, Name: model.NName, PID: model.PID }, function (data) {
                    if (data) {
                        toastr.success('添加成功');
                        model.modedata.push($.parseJSON(data))
                        model.NOrder = "";
                        model.NName = "";
                    }
                    else {
                    }
                });
            },
            deldata: function (el) {
                $.get("../Comon/ComAjaxHandler.ashx", { Action: "DelData", Table: "PT_Pro_Category", QueryCondition: " ID=" + el.ID }, function (data) {
                    if (data == "success") {
                        toastr.success('删除成功');
                        model.modedata.remove(el);
                    }
                    else {
                    }
                });
            }
        })
        avalon.ready(function () {
            $.getJSON("../Comon/ComAjaxHandler.ashx", { Action: "GetJsonData", Table: "PT_Pro_Category", QueryCondition: " AND TopID=" + model.PID }, function (data) {
                if (data) {
                    model.modedata = data;
                }
                else {
                }
            });
        })
    </script>
</head>
<body>
    <div class="container-fluid" ms-controller="MangnerSPLB" style="margin-top:20px">
        <table class="table table-bordered table-hover table-hover">
            <thead>
                <tr>
                    <th colspan="3">父菜单ID：{{PID}}</th>
                </tr>
                <tr>
                    <th>顺序</th>
                    <th>名称</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="modedata">
                    <td>{{el.Sort}}</td>
                    <td>{{el.MenuTxt}}</td>
                    <td><a class="text-danger" href="#" ms-click="deldata(el)">删除</a></td>

                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <th>
                        <input type="text" value="" class="form-control" ms-duplex="NOrder" /></th>
                    <th>
                        <input type="text" value="" class="form-control" ms-duplex="NName" /></th>
                    <th><a href="#" ms-click="adddata()">新增</a></th>
                </tr>
            </tfoot>
        </table>
    </div>
    <script src="../../JqueryPlug/Toast/toastr.js"></script>

</body>
</html>
